@model CaipuGuanliXitong.Models.DailyPurchaseDto
@{
    ViewData["Title"] = "每日采购食材结果";
}

<div class="container">
    <h2>每日采购食材结果</h2>
    
    <div class="row">
        <div class="col-md-12">
            <div class="card mb-4">
                <div class="card-header">
                    <h4>基本信息</h4>
                </div>
                <div class="card-body">
                    <dl class="row">
                        <dt class="col-sm-2">日期</dt>
                        <dd class="col-sm-10">@Model.Date.ToString("yyyy年MM月dd日")</dd>
                        
                        <dt class="col-sm-2">用餐人数</dt>
                        <dd class="col-sm-10">
                            早餐: 男 @Model.BreakfastMaleCount 人, 女 @Model.BreakfastFemaleCount 人<br>
                            午餐: 男 @Model.LunchMaleCount 人, 女 @Model.LunchFemaleCount 人<br>
                            晚餐: 男 @Model.DinnerMaleCount 人, 女 @Model.DinnerFemaleCount 人
                        </dd>
                    </dl>
                </div>
            </div>
        </div>
    </div>
    
    <div class="row">
        <div class="col-md-12">
            <div class="card mb-4">
                <div class="card-header">
                    <h4>当日菜谱</h4>
                </div>
                <div class="card-body">
                    @if (Model.MenuRecipes.Any())
                    {
                        <div class="table-responsive">
                            <table class="table table-striped table-bordered">
                                <thead>
                                    <tr>
                                        <th>餐次</th>
                                        <th>性别</th>
                                        <th>菜谱</th>
                                        <th>份数</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @foreach (var menuRecipe in Model.MenuRecipes)
                                    {
                                        <tr>
                                            <td>@menuRecipe.MealType</td>
                                            <td>@menuRecipe.Gender</td>
                                            <td>@menuRecipe.RecipeNames</td>
                                            <td>@menuRecipe.Count</td>
                                        </tr>
                                    }
                                </tbody>
                            </table>
                        </div>
                    }
                    else
                    {
                        <p>当日未设置菜谱</p>
                    }
                </div>
            </div>
        </div>
    </div>
    
    <div class="row">
        <div class="col-md-12">
            <div class="card mb-4">
                <div class="card-header">
                    <h4>早餐采购清单</h4>
                </div>
                <div class="card-body">
                    @if (Model.BreakfastDetails.Any())
                    {
                        <div class="table-responsive">
                            <table class="table table-striped table-bordered">
                                <thead>
                                    <tr>
                                        <th>食材名称</th>
                                        <th>单位</th>
                                        <th>数量</th>
                                        <th>单价</th>
                                        <th>金额</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @foreach (var detail in Model.BreakfastDetails)
                                    {
                                        <tr>
                                            <td>@detail.IngredientName</td>
                                            <td>@detail.IngredientUnit</td>
                                            <td>@detail.Quantity.ToString("F3")</td>
                                            <td>@detail.Price.ToString("F2")</td>
                                            <td>@detail.TotalAmount.ToString("F2")</td>
                                        </tr>
                                    }
                                </tbody>
                                <tfoot>
                                    <tr>
                                        <th colspan="4" class="text-right">小计</th>
                                        <th>@Model.BreakfastTotalAmount.ToString("F2")</th>
                                    </tr>
                                </tfoot>
                            </table>
                        </div>
                    }
                    else
                    {
                        <p>早餐无需采购食材</p>
                    }
                </div>
            </div>
        </div>
    </div>
    
    <div class="row">
        <div class="col-md-12">
            <div class="card mb-4">
                <div class="card-header">
                    <h4>午餐采购清单</h4>
                </div>
                <div class="card-body">
                    @if (Model.LunchDetails.Any())
                    {
                        <div class="table-responsive">
                            <table class="table table-striped table-bordered">
                                <thead>
                                    <tr>
                                        <th>食材名称</th>
                                        <th>单位</th>
                                        <th>数量</th>
                                        <th>单价</th>
                                        <th>金额</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @foreach (var detail in Model.LunchDetails)
                                    {
                                        <tr>
                                            <td>@detail.IngredientName</td>
                                            <td>@detail.IngredientUnit</td>
                                            <td>@detail.Quantity.ToString("F3")</td>
                                            <td>@detail.Price.ToString("F2")</td>
                                            <td>@detail.TotalAmount.ToString("F2")</td>
                                        </tr>
                                    }
                                </tbody>
                                <tfoot>
                                    <tr>
                                        <th colspan="4" class="text-right">小计</th>
                                        <th>@Model.LunchTotalAmount.ToString("F2")</th>
                                    </tr>
                                </tfoot>
                            </table>
                        </div>
                    }
                    else
                    {
                        <p>午餐无需采购食材</p>
                    }
                </div>
            </div>
        </div>
    </div>
    
    <div class="row">
        <div class="col-md-12">
            <div class="card mb-4">
                <div class="card-header">
                    <h4>晚餐采购清单</h4>
                </div>
                <div class="card-body">
                    @if (Model.DinnerDetails.Any())
                    {
                        <div class="table-responsive">
                            <table class="table table-striped table-bordered">
                                <thead>
                                    <tr>
                                        <th>食材名称</th>
                                        <th>单位</th>
                                        <th>数量</th>
                                        <th>单价</th>
                                        <th>金额</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @foreach (var detail in Model.DinnerDetails)
                                    {
                                        <tr>
                                            <td>@detail.IngredientName</td>
                                            <td>@detail.IngredientUnit</td>
                                            <td>@detail.Quantity.ToString("F3")</td>
                                            <td>@detail.Price.ToString("F2")</td>
                                            <td>@detail.TotalAmount.ToString("F2")</td>
                                        </tr>
                                    }
                                </tbody>
                                <tfoot>
                                    <tr>
                                        <th colspan="4" class="text-right">小计</th>
                                        <th>@Model.DinnerTotalAmount.ToString("F2")</th>
                                    </tr>
                                </tfoot>
                            </table>
                        </div>
                    }
                    else
                    {
                        <p>晚餐无需采购食材</p>
                    }
                </div>
            </div>
        </div>
    </div>
    
    <div class="row">
        <div class="col-md-12">
            <div class="card">
                <div class="card-header">
                    <h4>采购总计</h4>
                </div>
                <div class="card-body">
                    <dl class="row">
                        <dt class="col-sm-3">早餐采购金额</dt>
                        <dd class="col-sm-9">@Model.BreakfastTotalAmount.ToString("F2") 元</dd>
                        
                        <dt class="col-sm-3">午餐采购金额</dt>
                        <dd class="col-sm-9">@Model.LunchTotalAmount.ToString("F2") 元</dd>
                        
                        <dt class="col-sm-3">晚餐采购金额</dt>
                        <dd class="col-sm-9">@Model.DinnerTotalAmount.ToString("F2") 元</dd>
                        
                        <dt class="col-sm-3">总采购金额</dt>
                        <dd class="col-sm-9"><strong>@Model.TotalAmount.ToString("F2") 元</strong></dd>
                    </dl>
                </div>
            </div>
        </div>
    </div>
    
    <div class="row mt-3">
        <div class="col-md-12">
            <a class="btn btn-primary" asp-action="Calculate" asp-route-date="@Model.Date.ToString("yyyy-MM-dd")">重新计算</a>
            <a class="btn btn-secondary" asp-action="Index">返回</a>
            @* <a class="btn btn-success" asp-action="ExportToExcel" asp-route-date="@Model.Date.ToString("yyyy-MM-dd")">导出Excel</a> *@
        </div>
    </div>
</div>